using UnityEngine;

public class PlayerState_轻棍1 : PlayerStateBase
{
	private ItemSO_Data_Player招式_系数 _力竭系数;

	public PlayerState_轻棍1()
	{
		_Data_Player招式_系数 = MonoSingleton<MyDataManager>.Instance._Data_玩家招式._轻击_1;
		_力竭系数 = MonoSingleton<MyDataManager>.Instance._Data_玩家招式._轻击_0;
	}

	public override void OnEnter()
	{
		_Mono._Ani.Play("轻攻击1");
		_Mono._Rb2D.velocity = Vector2.zero;
		_Mono.F_玩家转向(Input.GetAxisRaw("Horizontal"));
		_Mono._Rb2D.AddForce(new Vector2((_Mono._朝向右边 ? 1 : (-1)) * 30, 0f), ForceMode2D.Impulse);
		_Timer = _Mono._Dict_AniName_time["轻攻击1"];
		_NextState = StateType_Player.正常移动;
		_Mono._State_攻击连段_判定Timer = _Timer + 0.5f;
		_Mono._State_攻击连段_判定 = StateType_Player.轻棍2;
		_Mono._C_攻击判断._击退力度 = 6f;
		if (_Mono._Curr气力 < _Data_Player招式_系数._气力消耗)
		{
			F_创建攻击命中回调(_力竭系数);
		}
		else
		{
			F_创建攻击命中回调();
		}
	}

	public override void OnExit()
	{
		_Mono._C_攻击判断._攻击命中回调 -= F_攻击命中回调;
	}

	public override void OnUpdate()
	{
		_Timer -= Time.deltaTime;
		if (_Timer <= 0f)
		{
			if (_NextState == StateType_Player.破棍式)
			{
				_Mono.ChangeToState(StateType_Player.破棍式);
				_Mono._Curr豆子--;
			}
			else if (_NextState == StateType_Player.轻棍2)
			{
				_Mono.ChangeToState(StateType_Player.轻棍2);
			}
			else
			{
				_Mono.ChangeState(StateType_Player.正常移动);
			}
		}
		if (Input.GetKeyDown(KeyCode.J))
		{
			F_轻攻击();
		}
		else if (Input.GetKeyDown(KeyCode.K))
		{
			F_重攻击Down();
		}
		else if (Input.GetKeyDown(KeyCode.L))
		{
			F_翻滚();
		}
	}

	public override void F_轻攻击()
	{
		_NextState = StateType_Player.轻棍2;
	}

	public override void F_重攻击Down()
	{
		if (_Mono._Curr豆子 >= 1)
		{
			_NextState = StateType_Player.破棍式;
		}
	}

	public override void F_翻滚()
	{
		_Mono.ChangeState(StateType_Player.翻滚);
	}
}
